﻿ 

namespace Common.Algorithm.Core.LocalTest;

 

public class NSGAIIRealExecute
{

    static BinhKornFunction function = new BinhKornFunction();
    public static List<double[]> Run()
    {
        //GetFunctions();

        NSGAIIRealService service = new NSGAIIRealService(
                new List<Func<double[], double>>()
                { function.GenMathFunction1(), function.GenMathFunction2() },
            function.ranges.ToList());
         
        Action action = () =>
        {
            service.RunAlgm(20);
        };
        Console.WriteLine($"time:{TimeService.TimeWatch(action)}");

        foreach (var sequence in NSGAIIRealService.sequences)
        {
            var doubles = sequence.genes;
            var v1 = function.GenMathFunction1().Invoke(doubles);
            var v2 = function.GenMathFunction2().Invoke(doubles);
            Console.WriteLine($"{doubles[0]},{doubles[1]}");
            Console.WriteLine($" {v1}, {v2}");
        }
        return NSGAIIRealService.records;
    }


    //public static List<Func<int[], double>> GetFunctions()
    //{
    //    Func<int[], double> func11 = (ints) =>
    //    {
    //        var doubles = function.BinaryDecode(ints);
    //        var func1 = function.GenMathFunction1();
    //        return func1(doubles);
    //    };

    //    Func<int[], double> func22 = (ints) =>
    //    {
    //        var doubles = function.BinaryDecode(ints);
    //        var func2 = function.GenMathFunction2();
    //        return func2(doubles);
    //    };
    //    return new List<Func<int[], double>>() { func11, func22 };
    //}



}

